package com.goodwill.androidtest.clonetest;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.concurrent.atomic.AtomicInteger;

public class CloneTest {
    public static void main(String[] args) {
        PriorityQueue<Double> queue = new PriorityQueue<>(new Comparator<Double>() {
            @Override
            public int compare(Double o1, Double o2) {
                return Double.compare(o2, o1);
            }
        });
        queue.add(3.1);
        queue.add(0.9);
        queue.add(10.9);

        AtomicInteger integer = new AtomicInteger();

        System.out.println(queue.toString());
        System.out.println("-----------------------");

        ArrayList<String> originList = new ArrayList<>();
        originList.add("1");
        originList.add("2");
        System.out.println("---------原始的数组 begin-------");
        System.out.println(originList.toString());
        System.out.println("---------原始的数组 end-------");
        ArrayList<String> cloneObj = (ArrayList<String>) originList.clone();
        System.out.println(cloneObj.toString());
        cloneObj.add("new_3");
        System.out.println("原始数组_第一次:" + originList.toString());
        System.out.println("拷贝数组_第一次:" + cloneObj.toString());
        originList.add("old_4");
        System.out.println("原始数组_第二次:" + originList.toString());
        System.out.println("拷贝数组_第二次:" + cloneObj.toString());
    }
}
